package nku.csc364;


/**
 * 
 * Raj Akula
 * CSC 365 Assignment 5
 * 
 * The person class which implements comparable, and overrides the equals method
 * so that a if the SSN field is equal to a string they objects are equal.
 *
 */



public class Person  implements Comparable{
	
	private String firstName;
	private String lastName;
	private String ssn;
	private String phoneNo;
	private char gender;
	private String dob;
	
	
	//Constructer setting default values
	public Person(String firstName, String lastName, String ssn,
			String phoneNo, char gender, String dob) {
		
		this.firstName = firstName;
		this.lastName = lastName;
		this.ssn = ssn;
		this.phoneNo = phoneNo;
		this.gender = gender;
		this.dob = dob;
	}
	
	
	//Setter and getter methods
	public String getPhoneNo() {
		return phoneNo;
	}
	public String getFirstName() {
		return firstName;
	}
	public String getLastName() {
		return lastName;
	}
	public String getSsn() {
		return ssn;
	}
	public char getGender() {
		return gender;
	}
	public String getDob() {
		return dob;
	}
	
	public void setLastName(String lname){
		this.lastName=lname;
	}
	
	public String toString(){
		
		return lastName+"\t"+firstName+"\t"+ssn+"\t"+phoneNo+"\t"+gender+"\t"+dob;
	}
	
	// Overwriting CompareTo methods
	public int compareTo(Object other) {
		 
		return ssn.compareTo(other.toString());			
	}
	
	// Overwriting Equals so if the social is the same for both of objects then 
	// they are equal to each other. 
	public boolean equals(Object obj) {
	
		boolean equality=false;
		if (obj instanceof Person){
			if (((Person) obj).getSsn().equals(ssn)){
				equality=true;
			}
		}else{
			if (obj.toString().equals(ssn)){
				equality=true;
			}
		}
		
			
		return equality;
	}
	
}	
